package com.powerunion.datacollection.web.struts;

import java.io.File;
import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;


import com.powerunion.datacollection.service.ViewDataManager;
import com.powerunion.util.log.LogHelper;

public class ViewDataAction extends DispatchAction {

	private static final Logger logger = LogHelper.getInstance().getLogger(
			ViewDataAction.class);
	private ViewDataManager vdManager = null;

	public ViewDataAction() {
		super();
		this.vdManager = new ViewDataManager();
	}

	public void finalize() throws Throwable {
		this.vdManager = null;
		super.finalize();
	}

	
	public ActionForward viewTasks(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		String userCode = request.getRemoteUser();
		String result = this.vdManager.getViewDataByUser(userCode);
		logger.debug("complete approve work:"+result);
		response.setContentType("text/json;charset=utf-8");
		try{
			response.getWriter().print(result);
		}catch(Exception e) {
			logger.error("输出json失败",e);
			return null;
		}
		return null;
	}

}
